<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        .container {
            width: 500px;
            /* 给父级元素设置高度清除浮动 */
            /* height: 500px; */
            background-color: #888;
/* overflow清除浮动 */
            /* overflow: hidden;
            clear: both; */
        }
  /* 伪对象清除浮动 */
        .container::after{
            content: "";
            display: block;
            clear: both;
        }

        .box {
            width: 100px;
            height: 100px;
            background-color: aqua;
            margin: 5px;
            float: left;
        }

        .text {
            width: 100px;
            height: 100px;
            background-color: blueviolet;
            /* clear: both; */         /*受影响的元素增加clear属性清除浮动*/
        }
    </style>
</head>

<body>

    <div class="container">
        <div class="box"></div>
        <div class="box"></div>
        <div class="box"></div>

    </div>
    <div class="text"></div>


</body>

</html>